
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.Statement" %>
<jsp:useBean id="user" class="com.user"></jsp:useBean>
<jsp:setProperty name="user" property="*"></jsp:setProperty>
<%
    Class.forName("com.mysql.jdbc.Driver");
    String url="jdbc:mysql://localhost:3306/book";
    Connection connection= DriverManager.getConnection(url,"root","root");

    Statement stmt=connection.createStatement();
    String sql="insert into user(username,password,gender,age) values('"+user.getUsername()+"','"+user.getPassword()+"',2,11)";

    //String sql="update user set age= 40 where id=5";

    //String sql="delete from username where id=4";
    int count=stmt.executeUpdate(sql);

    if(count>0){
        out.print("注册成功");
    }else{
        out.print("注册失败");
    }
%>